﻿using System;
using System.Collections.Generic;
using System.Text;

using Weazel.Badger.Vhdl;

namespace Weazel.Willows.InterfaceGeneration
{
	public class FifoElementRegistry
	{
		private Dictionary<int, DesignFile> queues =
			new Dictionary<int, DesignFile>();

		public List<String> GetFileNames()
		{
			List<string> result = new List<string>();
			foreach (DesignFile file in queues.Values)
				result.Add(file.FileName);
			return result;
		}

		public void WriteToDisk(string outputFolder)
		{
			foreach (DesignFile file in queues.Values)
				file.Write(outputFolder);
		}
		
		public FifoElementRegistry()
		{
		}

		public ComponentDeclaration GetFifoElementComponentDeclaration(int width)
		{
			if (queues.ContainsKey(width))
				return queues[width].Entities[0].GetDeclaration();

			DesignFile queue =
				FifoElementEntity.CreateFifoElementDesignFile(width);

			queues.Add(width, queue);

			return queue.Entities[0].GetDeclaration();
		}
	}
}
